import request from '@/utils/request'

// 获取结构树（脑图）
export function getMinder(query) {
  return request({
    url: '/fmea/common/structureTree/getMinder',
    method: 'get',
    params: query
  })
}

// 获取零件树
export function getBomTree(id) {
  return request({
    url: `/fmea/common/structureTree/getBomTree/${id}`,
    method: 'get'
  })
}

// 获取子级结构树
export function getMinderChildren(query) {
  return request({
    url: '/fmea/common/structureTree/getMinderChildren',
    method: 'get',
    params: query
  })
}

// 获取结构树
export function getStructureTree(query) {
  return request({
    url: '/fmea/common/structureTree/getStructureTree',
    method: 'get',
    params: query
  })
}

// 获取框图
export function getGraph(query) {
  return request({
    url: '/fmea/common/structureTree/getGraph',
    method: 'get',
    params: query
  })
}

// 获取节点关联
export function getNodeRelation(id) {
  return request({
    url: `/fmea/common/structureTree/${id}`,
    method: 'get'
  })
}

// 批量修改位置信息
export function batchUpdateLocation(data) {
  return request({
    url: '/fmea/common/structureTree/batchUpdateLocation',
    method: 'put',
    data: data
  })
}

// 结构树删除
export function removeStructureTree(data) {
  return request({
    url: '/fmea/common/structureTree/remove',
    method: 'delete',
    params: data
  })
}

// 节点排序
export function updateNodeOrder(data) {
  return request({
    url: `/fmea/common/structureTree/updateNodeOrder`,
    method: 'get',
    params: data
  })
}

// 获取节点排序列表
export function getSortableList(query) {
  return request({
    url: '/fmea/common/structureTree/getNodeOrderList',
    method: 'get',
    params: query
  })
}
// 获取关系网
export function getRelationNetwork(query) {
  return request({
    url: '/fmea/common/structureTree/getRelationNetwork',
    method: 'get',
    params: query
  })
}

export function getFunctionMatrix(data) {
  return request({
    url: `/fmea/common/structureTree/getRelationTree`,
    method: 'get',
    params: data
  })
}

export function sortFunc(data) {
  return request({
    url: `/fmea/common/structureTree/updateNodeOrder`,
    method: 'get',
    params: data
  })
}

export function getFailureMatrix(data) {
  return request({
    url: `/fmea/common/structureTree/getRelationTree`,
    method: 'get',
    params: data
  })
}

// 排序
export function sortFailure(params) {
  return request({
    url: `/fmea/common/structureTree/updateNodeOrder`,
    method: 'get',
    params: params
  })
}

// 获取新旧版本
export function getVersionContrast(query) {
  return request({
    url: `/fmea/common/structureTree/getVersionContrast`,
    method: 'get',
    params: query
  })
}

// 粘贴节点
export function copyStructure(query) {
  return request({
    url: '/fmea/common/structureTree/copyStructure',
    method: 'get',
    params: query
  })
}

// 基础fmea导入时的ztree树
export function getZtree(query) {
  return request({
    url: '/fmea/common/structureTree/getStructureZtreeByProjectId',
    method: 'get',
    params: query
  })
}

// 基础fmea导入
export function importBasicFmea(data) {
  return request({
    url: '/fmea/common/structureTree/importBasicFmeaStructure',
    method: 'post',
    data: data,
    timeout: 20000
  })
}

// 工艺流程图
export function getTmStepSymbolVo(query) {
  return request({
    url: '/fmea/common/structureTree/getTmStepSymbolVo',
    method: 'get',
    params: query
  })
}

// SOP
export function getSOP(query) {
  return request({
    url: '/fmea/common/structureTree/getSOP',
    method: 'get',
    params: query
  })
}

// SOP列表
export function getSOPList(query) {
  return request({
    url: '/fmea/common/project/selectSOPList',
    method: 'get',
    params: query
  })
}
